package com.xydtech.ecard.ecard.controller;

import com.xydtech.common.annotation.PassToken;
import com.xydtech.common.annotation.RsaRequest;
import com.xydtech.common.model.ResponseModel;
import com.xydtech.ecard.config.domain.EcardHomePageConfig;
import com.xydtech.ecard.config.service.IEcardHomePageConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * 电子名片-首页配置
 *
 * @author yuzhiguo
 * @date 2024/10/25 下午4:45
 */
@Controller
@Api(tags = "电子名片-首页配置")
@RequestMapping("/ecardSaasApi/config/homePage")
public class EcardApiHomePageConfigController  extends EcardApiBaseController {

    @Autowired
    private IEcardHomePageConfigService ecardHomePageConfigService;

    /**
     * 电子名片-电子名片-获取首页配置列表
     *
     * @author yuzhiguo
     * @date 2024/10/25 下午4:46
     */
    @PassToken
    @ApiOperation(value = "电子名片-电子名片-获取首页配置列表", notes = "电子名片-电子名片-获取首页配置列表")
    @ApiResponses({@ApiResponse(code = 0, message = "OK", response = ResponseModel.class)})
    @GetMapping("/findHomePageList")
    @ResponseBody
    @RsaRequest(param = false)
    public ResponseModel findHomePageList() {
        EcardHomePageConfig homePageConfig = new EcardHomePageConfig();
        homePageConfig.setState(1);//启用
        List<EcardHomePageConfig> ecardHomePageConfigList = ecardHomePageConfigService.selectEcardHomePageConfigList(homePageConfig);
        //后台限制启用的只有一条
        return ResponseModel.okToJSON(ecardHomePageConfigList.get(0));
    }
}
